#pragma once

#include <QPushButton>
#include <QLabel>


class Block : public QObject {
Q_OBJECT

public:
    enum class State {
        NORMAL,
        PRESSED,
        MARKED,
        UNKNOWN,
    };

    explicit Block(QWidget *widget);

    Block &setValue(int v);

    [[nodiscard]] int getValue() const;

    Block &setPosition(int x_, int y_);

    std::pair<int, int> getPosition();

    void setWrong();

    void setRed();

    void press();

    void mark();

    void reset();

    [[nodiscard]] bool isPressed() const;

    const State &state = m_state;

signals:

#pragma clang diagnostic push
#pragma ide diagnostic ignored "NotImplementedFunctions"

    void pressed(Block *block);

    void marked(Block *block);

    void entered(Block *block);

    void leaved(Block *block);

#pragma clang diagnostic pop

private slots:

    void onClick();

private:
    void setStyle();

    bool eventFilter(QObject *obj, QEvent *ev) override;

    QLabel label;
    QPushButton button;
    int value = 0;
    int x = 0;
    int y = 0;
    State m_state = State::NORMAL;
};
